<?php
namespace App\Admin\Models;
use Common\BaseModel;
class AdUserProbability extends BaseModel
{
    protected $res;
    protected $redis_key="admin_";
    public function initialize()
    {
        parent::initialize();
        $this->setSource('ad_user_probability');
    }

    public function get_redwallet($type='redwallet'){
        $conditions = "type='{$type}'";
        $get_list = $this->find(array(
            $conditions
        ))->toarray();
        foreach($get_list as $key=>$value){
            if($value['pid'] != 0){
                $value_value = explode('-',$value['value']);
                $get_list[$key]['value_start'] = $value_value[0];
                $get_list[$key]['value_end'] = $value_value[1];
            }else{
                $get_list[$key]['value_start'] = 0;
                $get_list[$key]['value_end'] = 0;
            }
        }
        return $get_list;
    }


    public function find_by_id($id){
        return $this->findFirstById($id);
    }

}
